function [var sd] = var_only_growth(id,year,X,w)

[h1,h2,ii] = unique(id);
[h1,h2,jj] = unique(year);

N = max(ii);
T = max(jj);

bigX = zeros(N,T);
bigX(sub2ind([N T],ii,jj)) = X;

bigO = zeros(N,T);
bigO(sub2ind([N T],ii,jj)) = 1;
counts = sum(bigO,2);

mX = sum(bigX,2)./sum(bigO,2);
demeanX = (bigX-repmat(mX,1,T)).*bigO;



Y = reshape(demeanX,N,T);

t = counts - ones(size(counts,1),1);
tt = repmat(t,1,T);
TT = reshape(tt,N,T);

Y = Y./sqrt(TT);



W = zeros(N,T);
W(sub2ind([N T],ii,jj)) = w;


Z = repmat(sum(Y.Y*,2),1,T);


y = W.*W.*Z

var = sum(y,1)';
sd = sqrt(var);

